<meta charset="utf-8">
(#) LiveData value assignment nullability mismatch

!!! ERROR: LiveData value assignment nullability mismatch
   This is an error, and is also enforced at build time when
   supported by the build system. For Android this means it will
   run during release builds.

Id
:   `NullSafeMutableLiveData`
Summary
:   LiveData value assignment nullability mismatch
Severity
:   Fatal
Category
:   Interoperability: Kotlin Interoperability
Platform
:   Android
Vendor
:   Android Open Source Project
Identifier
:   androidx.lifecycle
Feedback
:   https://issuetracker.google.com/issues/new?component=413132
Min
:   Lint 7.0
Compiled
:   Lint 8.0 and 8.1
Artifact
:   [androidx.lifecycle:lifecycle-livedata-core-ktx](androidx_lifecycle_lifecycle-livedata-core-ktx.md.html)
Since
:   2.3.0
Affects
:   Kotlin and Java files
Editing
:   This check runs on the fly in the IDE editor
Implementation
:   [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-lint/src/main/java/androidx/lifecycle/lint/NonNullableMutableLiveDataDetector.kt)
Tests
:   [Source Code](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:/lifecycle/lifecycle-livedata-core-lint/src/test/java/androidx/lifecycle/livedata/core/lint/NonNullableMutableLiveDataDetectorTest.kt)
Copyright Year
:   2019

This check ensures that LiveData values are not null when explicitly
            declared as non-nullable.

                Kotlin interoperability does not support enforcing
explicit null-safety when using                 generic Java type
parameters. Since LiveData is a Java class its value can always
       be null even when its type is explicitly declared as
non-nullable. This can lead                 to runtime exceptions from
reading a null LiveData value that is assumed to be
non-nullable.

!!! Tip
   This lint check has an associated quickfix available in the IDE.

(##) Repackaged

This lint check appears to have been packaged in other artifacts as
well. Issue id's must be unique, so you cannot combine these libraries.
Also defined in:
* NullSafeMutableLiveData: LiveData value assignment nullability mismatch (this issue)
* [NullSafeMutableLiveData from androidx.lifecycle:lifecycle-livedata-core:2.9.0-alpha08](NullSafeMutableLiveData.md.html)
* [NullSafeMutableLiveData from androidx.lifecycle:lifecycle-livedata-core-ktx:2.8.0-alpha01](NullSafeMutableLiveData-2.md.html)


(##) Including

!!!
   This is not a built-in check. To include it, add the below dependency
   to your project.

```
// build.gradle.kts
implementation("androidx.lifecycle:lifecycle-livedata-core-ktx:2.8.0-alpha01")

// build.gradle
implementation 'androidx.lifecycle:lifecycle-livedata-core-ktx:2.8.0-alpha01'

// build.gradle.kts with version catalogs:
implementation(libs.lifecycle.livedata.core.ktx)

# libs.versions.toml
[versions]
lifecycle-livedata-core-ktx = "2.8.0-alpha01"
[libraries]
# For clarity and text wrapping purposes the following declaration is
# shown split up across lines, but in TOML it needs to be on a single
# line (see https://github.com/toml-lang/toml/issues/516) so adjust
# when pasting into libs.versions.toml:
lifecycle-livedata-core-ktx = {
    module = "androidx.lifecycle:lifecycle-livedata-core-ktx",
    version.ref = "lifecycle-livedata-core-ktx"
}
```

2.8.0-alpha01 is the version this documentation was generated from;
there may be newer versions available.

[Additional details about androidx.lifecycle:lifecycle-livedata-core-ktx](androidx_lifecycle_lifecycle-livedata-core-ktx.md.html).
(##) Suppressing

You can suppress false positives using one of the following mechanisms:

* Using a suppression annotation like this on the enclosing
  element:

  ```kt
  // Kotlin
  @Suppress("NullSafeMutableLiveData")
  fun method() {
     problematicStatement()
  }
  ```

  or

  ```java
  // Java
  @SuppressWarnings("NullSafeMutableLiveData")
  void method() {
     problematicStatement();
  }
  ```

* Using a suppression comment like this on the line above:

  ```kt
  //noinspection NullSafeMutableLiveData
  problematicStatement()
  ```

* Using a special `lint.xml` file in the source tree which turns off
  the check in that folder and any sub folder. A simple file might look
  like this:
  ```xml
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;lint&gt;
      &lt;issue id="NullSafeMutableLiveData" severity="ignore" /&gt;
  &lt;/lint&gt;
  ```
  Instead of `ignore` you can also change the severity here, for
  example from `error` to `warning`. You can find additional
  documentation on how to filter issues by path, regular expression and
  so on
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).

* In Gradle projects, using the DSL syntax to configure lint. For
  example, you can use something like
  ```gradle
  lintOptions {
      disable 'NullSafeMutableLiveData'
  }
  ```
  In Android projects this should be nested inside an `android { }`
  block.

* For manual invocations of `lint`, using the `--ignore` flag:
  ```
  $ lint --ignore NullSafeMutableLiveData ...`
  ```

* Last, but not least, using baselines, as discussed
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).

<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script src="https://morgan3d.github.io/markdeep/latest/markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>